package com.ymatou.iapi.dguser.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.GetUserBelongSellerIdBean;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.dguser.service.GetUserBelongSellerIdCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
/**
*获取用户belong成功
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetUserBelongSellerId{
	private static GetUserBelongSellerIdBean getuserbelongselleridBean;
	private static GetUserBelongSellerIdCall getuserbelongselleridCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取用户belong成功");
	}

	@Before
	public void caseUp() {
		getuserbelongselleridBean=new GetUserBelongSellerIdBean();
		getuserbelongselleridCall=new GetUserBelongSellerIdCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getuserbelongselleridCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserBelongSellerId_001() {
		Logger.start(true,"获取用户belong成功");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			u.setBelongSellerId(1);
			int user = DGUserCallService.UserCreateCall(u);
			getuserbelongselleridBean.setUserId(user);
			getuserbelongselleridCall.setData(getuserbelongselleridBean);
			getuserbelongselleridCall.callService();			
			Logger.verifyEquals("true", getuserbelongselleridCall.getString("success"), "验证success");
			Logger.verifyEquals("1", getuserbelongselleridCall.getString("belongSellerId"), "验证belongSellerId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetUserBelongSellerId_002() {
		Logger.start(true,"不输入userid失败");
		try {
//			getuserbelongselleridBean.setUserId(user);
			getuserbelongselleridCall.setData(getuserbelongselleridBean);
			getuserbelongselleridCall.callService();			
			Logger.verifyEquals("false", getuserbelongselleridCall.getString("success"), "验证success");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetUserBelongSellerId_003() {
		Logger.start(true,"输入不存在userid失败");
		try {
			getuserbelongselleridBean.setUserId(1);
			getuserbelongselleridCall.setData(getuserbelongselleridBean);
			getuserbelongselleridCall.callService();			
			Logger.verifyEquals("false", getuserbelongselleridCall.getString("success"), "验证success");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserBelongSellerId_004() {
		Logger.start(true,"BelongSellerId为null时返回0");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			u.setBelongSellerId(null);
			int user = DGUserCallService.UserCreateCall(u);
			getuserbelongselleridBean.setUserId(user);
			getuserbelongselleridCall.setData(getuserbelongselleridBean);
			getuserbelongselleridCall.callService();			
			Logger.verifyEquals("true", getuserbelongselleridCall.getString("success"), "验证success");
			Logger.verifyEquals("0", getuserbelongselleridCall.getString("belongSellerId"), "验证belongSellerId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}